import 'package:flutter_application_1/models/recommend_interface.dart';
import 'package:flutter_application_1/models/user_model.dart';

class ArticleList {
  late final List<ArticleItem> list;
  ArticleList(this.list);
  factory ArticleList.fromJson(List<dynamic> list) {
    return ArticleList(
      list.map((e) => ArticleItem.fromJson(e)).toList(),
    );
  }
}

class ArticleItem implements RecommendInterface {
  late final int id;
  late final int userId;
  late final List coverUrlList;
  late final String title;
  late final int commentCount;
  late final int thumbUpCount;
  late final int readCount;
  late UserItem user;

  ArticleItem({
    required this.id,
    required this.userId,
    required this.coverUrlList,
    required this.title,
    required this.commentCount,
    required this.thumbUpCount,
    required this.readCount,
    required this.user,
  });

  factory ArticleItem.fromJson(dynamic item) {
    return ArticleItem(
      id: item["id"],
      userId: item["userId"],
      coverUrlList: item["coverUrlList"],
      title: item["title"],
      commentCount: item["commentCount"],
      thumbUpCount: item["thumbUpCount"],
      readCount: item["readCount"],
      user: UserItem.fromJson(item["user"]),
    );
  }
}
